Skip to content

feat(cloud-shared): rebrand-ready agent base domain config (waifu.fun → elizacloud.ai prep)#7896

Open
standujar wants to merge 3 commits into
developfrom
feat/cloud-rebrand-domains
Open

feat(cloud-shared): rebrand-ready agent base domain config (waifu.fun → elizacloud.ai prep)#7896
standujar wants to merge 3 commits into
developfrom
feat/cloud-rebrand-domains

Conversation

@standujar
Copy link
Copy Markdown
Collaborator

@standujar standujar commented May 23, 2026

Summary

Prepare the cloud-shared layer for the rebrand from waifu.fun / milady.ai / shad0w.xyz to elizacloud.ai. Runtime impact: zero until ELIZA_CLOUD_AGENT_BASE_DOMAIN flips in deployment env. This PR is one of several coordinated commits that ship the rebrand without breaking existing sandbox URLs.

Changes

  1. DOMAIN_ALIAS_GROUPS extended from the original [waifu.fun, eliza.ai] pair to the full 5-domain group:

    [".waifu.fun", ".eliza.ai", ".elizacloud.ai", ".milady.ai", ".shad0w.xyz"]

    The pairing-token CORS Origin validator now tries every alternate, so a token issued against <uuid>.waifu.fun validates when the user reaches <uuid>.elizacloud.ai (or any other group member). Without this, the rebrand would break in-flight pair handshakes.

  2. Pure module extraction: getAlternateDomainOrigins() + the DOMAIN_ALIAS_GROUPS constant move into a new file pairing-token-domains.ts so the alias logic is unit-testable without dragging the Postgres repository import chain. The DB-bound PairingTokenService in pairing-token.ts re-exports the same names for back-compat with existing callers.

  3. DEFAULT_AGENT_BASE_DOMAIN in eliza-agent-web-ui.ts flips from "waifu.fun" to "elizacloud.ai". A fresh deploy without ELIZA_CLOUD_AGENT_BASE_DOMAIN set picks the rebrand brand by default. Existing deployments override via env var (currently "milady.ai" on the prod manager VM) and stay unchanged.

  4. Stale comment fix in eliza-sandbox.ts:2190: replaced // Public URL: https://{agentId}.waifu.fun/... with the env-var-templated equivalent so the comment ages with the deployment.

Tests

8 sociable specs in pairing-token.test.ts:

  • Every domain in the group resolves to the 4 others
  • Suffix anchoring (abc.notwaifu.fun does NOT alias)
  • UUID prefix preservation across rewrites
  • Port round-trip (https://abc.waifu.fun:8443https://abc.eliza.ai:8443)
  • Unparseable input returns []
  • DOMAIN_ALIAS_GROUPS declares .elizacloud.ai (the rebrand-target guarantee)
  • Suffixes are leading-dot anchored

bun test packages/cloud-shared/src/lib/services/pairing-token.test.ts8/8 pass.

What this PR does NOT do

  • Set ELIZA_CLOUD_AGENT_BASE_DOMAIN=elizacloud.ai in deployed env — that's an ops action, separate from code
  • Create new DNS records or Cloudflare tunnel ingress entries — also ops
  • Touch the existing 22 agent_sandboxes rows (their bridge_url uses direct IPs, not affected by DNS)
  • Drop .waifu.fun / .milady.ai / .shad0w.xyz from the alias group — they stay during the grace period so existing pair tokens validate

Verification

  • bun test packages/cloud-shared/src/lib/services/pairing-token.test.ts
  • bunx tsc --noEmit on packages/cloud-shared (clean, only pre-existing core/shared @elizaos/contracts noise)
  • bunx @biomejs/biome check on touched files (clean)
  • After merge: flip ELIZA_CLOUD_AGENT_BASE_DOMAIN=elizacloud.ai on the prod manager VM .env.local and restart the daemons (ops, not in this PR)

Greptile Summary

This PR prepares cloud-shared for the waifu.funelizacloud.ai rebrand by expanding the CORS domain alias group from 2 to 5 entries and extracting the alias logic into a standalone, testable module.

  • pairing-token-domains.ts (new): pure module holding DOMAIN_ALIAS_GROUPS (5-domain group) and getAlternateDomainOrigins(), unit-tested by the accompanying 8-spec suite; pairing-token.ts re-exports both names for backward compat.
  • eliza-agent-web-ui.ts: default domain flips to elizacloud.ai; deployments with ELIZA_CLOUD_AGENT_BASE_DOMAIN set are unaffected.
  • eliza-sandbox.ts: stale hardcoded waifu.fun comment replaced with the env-var template.

Confidence Score: 4/5

Safe to merge; changes are additive and gated behind an env-var flip that has not yet happened in production.

The core rebrand logic is correct and well-tested. The two findings are minor: hashToken is recomputed redundantly on each loop iteration rather than cached, and the regex/replacement construction in getAlternateDomainOrigins only escapes dots, leaving a latent trap if a domain with other metacharacters or a $ is ever added. Neither affects current runtime behavior.

pairing-token-domains.ts and pairing-token.ts carry the new alias logic and are worth a second look for the points above.

Important Files Changed

Filename Overview
packages/cloud-shared/src/lib/services/pairing-token-domains.ts New file extracting domain alias logic into a pure, testable module; regex escaping only handles dots, leaving a latent fragility for future non-dot metacharacters or dollar-sign replacement patterns in candidate domain names.
packages/cloud-shared/src/lib/services/pairing-token.ts Replaces single-pair alias lookup with a multi-domain loop; hashToken is recomputed on every loop iteration instead of being cached before the first call.
packages/cloud-shared/src/lib/services/pairing-token.test.ts New test suite covering all 5 alias domains, boundary anchoring, port round-trip, unparseable input, and the rebrand guarantee; good coverage of the extracted pure function.
packages/cloud-shared/src/lib/eliza-agent-web-ui.ts Straightforward default domain rename from waifu.fun to elizacloud.ai; env-var override path is unchanged so existing deployments are unaffected.
packages/cloud-shared/src/lib/services/eliza-sandbox.ts One-line stale comment fix replacing a hardcoded waifu.fun reference with the env-var template; no logic change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["validateToken(token, origin)"] --> B["normalizeOrigin(origin)"]
    B --> C["hashToken(token)"]
    C --> D["consumeValidToken(hash, normalizedOrigin)"]
    D -->|row found| E["return PairingToken"]
    D -->|null| F["getAlternateDomainOrigins(normalizedOrigin)"]
    F --> G["DOMAIN_ALIAS_GROUPS\n[.waifu.fun, .eliza.ai, .elizacloud.ai,\n .milady.ai, .shad0w.xyz]"]
    G --> H{"loop alternates"}
    H --> I["consumeValidToken(hash, alternateOrigin)\n← hash re-computed each iteration"]
    I -->|row found| E
    I -->|null| H
    H -->|exhausted| J["return null"]
Loading

Comments Outside Diff (1)

  1. packages/cloud-shared/src/lib/services/pairing-token.ts, line 89-108 (link)

    P2 hashToken is an async SHA-256 digest, and the result is identical on every call for the same token. Currently it is awaited once for the exact-origin check and then re-awaited on every iteration of the alternates loop (up to 4 more times). Computing it once and reusing the result avoids redundant crypto work on every miss.

Reviews (1): Last reviewed commit: "feat(cloud-shared): rebrand-ready agent ..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Three coordinated changes prepare the cloud-shared layer for the
in-flight rebrand from waifu.fun / milady.ai / shad0w.xyz to
elizacloud.ai, all gated on env vars so the runtime impact is zero
until ELIZA_CLOUD_AGENT_BASE_DOMAIN flips in deployment env:

1. `DOMAIN_ALIAS_GROUPS` extended from the original
   [waifu.fun, eliza.ai] pair to the full 5-domain group
   [waifu.fun, eliza.ai, elizacloud.ai, milady.ai, shad0w.xyz]. The
   pairing-token CORS Origin check now tries every alternate, so a
   token issued against `<uuid>.waifu.fun` validates when the user
   reaches `<uuid>.elizacloud.ai` (or any other group member).

   The alias resolver is extracted into a standalone pure module
   `pairing-token-domains.ts` so it can be unit-tested without
   dragging in the Postgres repository import chain. The DB-bound
   service in `pairing-token.ts` re-exports the same names for back
   compat with existing callers.

2. `DEFAULT_AGENT_BASE_DOMAIN` in `eliza-agent-web-ui.ts` flips
   from "waifu.fun" to "elizacloud.ai" so a fresh deploy without
   `ELIZA_CLOUD_AGENT_BASE_DOMAIN` set picks the rebrand brand by
   default. Existing deployments override via the env var (currently
   set to "milady.ai" on the prod manager VM) — unchanged.

3. Stale comment `Public URL: https://{agentId}.waifu.fun/...` in
   eliza-sandbox.ts replaced with the env-var-templated equivalent so
   the comment ages with the deployment, not against it.

Tests: 8 sociable specs in `pairing-token.test.ts` cover the alias
matrix (suffix anchoring, UUID prefix preservation, port round-trip,
unparseable input, group membership guarantee). bun test 8/8 pass.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f6c7938e-4ca2-4582-b3f7-b81c36379779

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cloud-rebrand-domains

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the Tests label May 23, 2026
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 23, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

Comment on lines +39 to +42
altUrl.hostname = url.hostname.replace(
new RegExp(`${matched.replaceAll(".", "\\.")}$`),
candidate,
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Partial regex escaping may break for future domain entries. matched.replaceAll(".", "\\.") only escapes dots. If a future domain suffix ever contains other regex metacharacters (e.g. +, *, (, )), they will be interpreted as regex operators rather than literal characters, silently producing a wrong hostname. Additionally, candidate is passed directly as the replacement string to String.prototype.replace(), where $&, $', and $n have special meaning — a domain suffix containing $ would corrupt the output. Current domains are safe, but a small escapeRegExp / escapeReplacement guard would make this maintainable as the alias group grows.

@standujar standujar marked this pull request as draft May 23, 2026 09:38
standujar added 2 commits May 23, 2026 12:00
…s group

Audit of agent_pairing_tokens (90d) and agent_sandboxes.bridge_url
shows 0 prod rows under .milady.ai or .shad0w.xyz. Both were 0xSolace-
era domains:

  - .milady.ai resolves to GitHub Pages (static front, never served
    sandbox HTTP infra)
  - .shad0w.xyz was a personal-handle dev convenience

Keeping them in the alias group would silently keep "0 legacy" from
being true. Drop both. Old bookmarks under those domains now fail
Origin validation, which is the intended outcome.

The remaining group is the three Eliza brands [waifu.fun, eliza.ai,
elizacloud.ai]. .elizacloud.ai is the post-2026-05 canonical; the
others ride along during the rebrand grace period.
Five parallel agents (Slop, Types, Dead Code, Defensive, Tests) audited
the rebrand-ready domain config. Changes that landed:

- Removed dead re-export of `DOMAIN_ALIAS_GROUPS`/`getAlternateDomainOrigins`
  from `pairing-token.ts` (Agent 1). The test + caller both import
  directly from the pure module, so the re-export was slop.
- Simplified the inner-loop URL construction in `pairing-token-domains.ts`
  (Agent 4): `new URL(url.toString())` collapses to `new URL(url)`, and
  the per-iteration RegExp allocation is replaced with a constant-time
  slice now that the matched suffix length is known.
- Added two test cases (Agents 4 + 5): an uppercase-hostname input
  (verifies WHATWG URL parser lowercasing makes `endsWith` work) and a
  subdomain-depth input (`a.b.c.waifu.fun`) to lock in the slice-based
  algorithm's prefix preservation.
- Tightened a weak assertion (`toBeGreaterThan(0)` →
  `toHaveLength(2)`) in the port-preservation test.

All decisions explicitly kept the alias mechanism's surface area — the
extraction of `pairing-token-domains.ts`, the `try/catch` for
unparseable input, the readonly group shape, and the outer-loop over
groups all justified by Agents 2-5 audits.

Tests: 11 pass / 33 expect() calls (was 9/31).
@standujar standujar marked this pull request as ready for review May 23, 2026 10:18
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 23, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 23, 2026

Summary

Prepare the cloud-shared layer for the rebrand from waifu.fun / milady.ai / shad0w.xyz to elizacloud.ai. Runtime impact: zero until ELIZA_CLOUD_AGENT_BASE_DOMAIN flips in deployment env. This PR is one of several coordinated commits that ship the rebrand without breaking existing sandbox URLs.

Changes

  1. DOMAIN_ALIAS_GROUPS extended from the original [waifu.fun, eliza.ai] pair to the full 5-domain group:

    [".waifu.fun", ".eliza.ai", ".elizacloud.ai", ".milady.ai", ".shad0w.xyz"]

    The pairing-token CORS Origin validator now tries every alternate, so a token issued against <uuid>.waifu.fun validates when the user reaches <uuid>.elizacloud.ai (or any other group member). Without this, the rebrand would break in-flight pair handshakes.

  2. Pure module extraction: getAlternateDomainOrigins() + the DOMAIN_ALIAS_GROUPS constant move into a new file pairing-token-domains.ts so the alias logic is unit-testable without dragging the Postgres repository import chain. The DB-bound PairingTokenService in pairing-token.ts re-exports the same names for back-compat with existing callers.

  3. DEFAULT_AGENT_BASE_DOMAIN in eliza-agent-web-ui.ts flips from "waifu.fun" to "elizacloud.ai". A fresh deploy without ELIZA_CLOUD_AGENT_BASE_DOMAIN set picks the rebrand brand by default. Existing deployments override via env var (currently "milady.ai" on the prod manager VM) and stay unchanged.

  4. Stale comment fix in eliza-sandbox.ts:2190: replaced // Public URL: https://{agentId}.waifu.fun/... with the env-var-templated equivalent so the comment ages with the deployment.

Tests

8 sociable specs in pairing-token.test.ts:

  • Every domain in the group resolves to the 4 others
  • Suffix anchoring (abc.notwaifu.fun does NOT alias)
  • UUID prefix preservation across rewrites
  • Port round-trip (https://abc.waifu.fun:8443https://abc.eliza.ai:8443)
  • Unparseable input returns []
  • DOMAIN_ALIAS_GROUPS declares .elizacloud.ai (the rebrand-target guarantee)
  • Suffixes are leading-dot anchored

bun test packages/cloud-shared/src/lib/services/pairing-token.test.ts8/8 pass.

What this PR does NOT do

  • Set ELIZA_CLOUD_AGENT_BASE_DOMAIN=elizacloud.ai in deployed env — that's an ops action, separate from code
  • Create new DNS records or Cloudflare tunnel ingress entries — also ops
  • Touch the existing 22 agent_sandboxes rows (their bridge_url uses direct IPs, not affected by DNS)
  • Drop .waifu.fun / .milady.ai / .shad0w.xyz from the alias group — they stay during the grace period so existing pair tokens validate

Verification

  • bun test packages/cloud-shared/src/lib/services/pairing-token.test.ts
  • bunx tsc --noEmit on packages/cloud-shared (clean, only pre-existing core/shared @elizaos/contracts noise)
  • bunx @biomejs/biome check on touched files (clean)
  • After merge: flip ELIZA_CLOUD_AGENT_BASE_DOMAIN=elizacloud.ai on the prod manager VM .env.local and restart the daemons (ops, not in this PR)

Greptile Summary

This PR prepares cloud-shared for the rebrand from waifu.fun / eliza.ai to elizacloud.ai by extending the CORS domain alias group, extracting that logic into a standalone testable module, flipping the default base domain, and fixing a stale comment. Runtime impact is zero until the deployment env var is changed.

  • pairing-token-domains.ts (new file): Moves DOMAIN_ALIAS_GROUPS and getAlternateDomainOrigins out of pairing-token.ts and expands the alias group from 2 to 3 domains (.waifu.fun, .eliza.ai, .elizacloud.ai); .milady.ai and .shad0w.xyz are intentionally excluded with clear comments and a dedicated test asserting the exclusion.
  • pairing-token.ts: Replaces the private 2-way alias helper with a loop over the new N-ary getAlternateDomainOrigins, correctly short-circuiting on the first match.
  • eliza-agent-web-ui.ts / eliza-sandbox.ts: Default domain constant and a stale comment updated from waifu.fun to elizacloud.ai; behavior is controlled entirely by the ELIZA_CLOUD_AGENT_BASE_DOMAIN env var.

Confidence Score: 5/5

Safe to merge — the changes are purely additive during the grace period, and the env-var guard means no live deployment is affected until ops explicitly flips the variable.

The alias-group extraction is well-tested (8 targeted specs), the fallback loop short-circuits correctly, and the default-domain flip has zero runtime impact until the deployment env var changes. No auth bypass, no data mutation, no migration.

No files require special attention. The one inconsistency worth a quick look is whether the PR description's claim about the alias group matches team intent — the code and tests tell a clear story, but the description says something different.

Important Files Changed

Filename Overview
packages/cloud-shared/src/lib/services/pairing-token-domains.ts New module extracting domain alias logic for testability; clean implementation with leading-dot anchoring and URL-parser-safe case normalization.
packages/cloud-shared/src/lib/services/pairing-token.ts Replaced the private 2-domain alias method with a loop over getAlternateDomainOrigins; logic is correct but hashToken is re-computed on every alternate iteration (pre-existing concern already noted in prior review).
packages/cloud-shared/src/lib/services/pairing-token.test.ts 8 well-structured tests covering suffix anchoring, UUID prefix preservation, port round-trip, unparseable input, and the rebrand guarantee; good coverage.
packages/cloud-shared/src/lib/eliza-agent-web-ui.ts Default domain constant and JSDoc string updated from waifu.fun to elizacloud.ai; env-var override path unchanged.
packages/cloud-shared/src/lib/services/eliza-sandbox.ts Single-line stale comment updated from hardcoded waifu.fun to env-var-templated equivalent; no logic change.

Sequence Diagram

sequenceDiagram
    participant Client as Browser (Origin: uuid.elizacloud.ai)
    participant Service as PairingTokenService
    participant Domains as getAlternateDomainOrigins
    participant DB as agentPairingTokensRepository

    Client->>Service: validateToken(token, "https://uuid.elizacloud.ai")
    Service->>DB: consumeValidToken(hash, "https://uuid.elizacloud.ai")
    DB-->>Service: null (token stored with waifu.fun origin)

    Service->>Domains: getAlternateDomainOrigins("https://uuid.elizacloud.ai")
    Domains-->>Service: ["https://uuid.waifu.fun", "https://uuid.eliza.ai"]

    loop For each alternate origin
        Service->>DB: consumeValidToken(hash, "https://uuid.waifu.fun")
        DB-->>Service: PairingTokenRow (match found)
        Note over Service: break - token consumed
    end

    Service-->>Client: PairingToken
Loading

Comments Outside Diff (1)

  1. packages/cloud-shared/src/lib/services/pairing-token.ts, line 89-108 (link)

    P2 hashToken is an async SHA-256 digest, and the result is identical on every call for the same token. Currently it is awaited once for the exact-origin check and then re-awaited on every iteration of the alternates loop (up to 4 more times). Computing it once and reusing the result avoids redundant crypto work on every miss.

Reviews (2): Last reviewed commit: "chore(cloud-shared): /clean follow-ups o..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant